# -*- coding: utf-8 -*-
"""
Created on Tue Aug  2 09:18:50 2016

@author: XT-YY

get fund data from wind and ifeng
"""

from splinter import Browser
import pandas as pd
import time
import os

src_path = r".\data" # relative path
dst_path = r"D:\data\FundData"

def dateTransform(date):
    return date[0:4]+"-"+date[4:6]+"-"+date[6:8]



if __name__ == "__main__":
    sdate = "20150101"
    edate = "20160802"
    browser = Browser('phantomjs', user_agent="Mozilla/5.0 (Windows NT 6.1; WOW64) \
        AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36")
#    browser = Browser()
    browser.driver.maximize_window()
    url = r"http://quotes.money.163.com/fund/zyjl_511880_0.html?start="+dateTransform(sdate) \
    +"&end="+dateTransform(edate)+"&sort=TDATE&order=desc"
    browser.visit(url)
    time.sleep(3)
    xpath = '//*[@id="fn_fund_value_trend"]/table/tbody'
    table = browser.find_by_xpath(xpath).first.text
    col_name = ["#Ticker", "date", "close", "volume", ""]
    values = []
    
    